package design_pattern.trigger;

import design_pattern.trigger.frame.*;

/**
 * @version 1.0.0
 * Created by cyd on 2022-08-29 17:12:21
 * @ClassName : design_pattern.trigger.NobleMan
 * @Description : 定义贵族，能够处理的事件的级别
 */
public class NobleMan extends AbstractEventConsumer {

    // 定义贵族能够处理的事件的级别
    public NobleMan() {
        super(EventConsumerType.EDIT);
        super.addCustomType(EventConsumerType.CLONE);
    }

    @Override
    public void exec(ProductEvent event) {
        //事件的源头
        Product product = event.getSource();

        //事件类型
        ProductEventType type = event.getEventType();

        if (type.getValue() == EventConsumerType.CLONE.getValue()) {
            System.out.println("贵族处理事件: " + product.getName() + "克隆, 事件类型 = " + type);
        } else {
            System.out.println("贵族处理事件: " + product.getName() + "修改, 事件类型 = " + type);
        }
    }

}

